import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import "./plugins/element.js";
// 导入树形表格组件
import TreeTable from "vue-table-with-tree-grid";
// 全局样式
import "./assets/css/global.css";
// 导入富文本编辑器
import VueQuillEditor from "vue-quill-editor";
// 导入富文本编辑器对应的样式
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";

// http请求
import axios from "axios";
axios.defaults.baseURL = "http://127.0.0.1:8888/api/private/v1/";
Vue.prototype.$http = axios;
// 请求拦截器，对请求进行预处理，为请求头加上token令牌，有令牌才能放行
axios.interceptors.request.use((config) => {
  // console.log(config);
  // NProgress.start(); /* 触发了request说明发起请求了 显示进度条 */
  config.headers.Authorization = window.sessionStorage.getItem("token");
  // 在最后必须return
  return config;
});

// 使用树形表格组件
Vue.component("tree-table", TreeTable);

// 将富文本编辑器, 注册为全局可用的组件
Vue.use(VueQuillEditor);

Vue.config.productionTip = false;

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");
